import requests
import json

url = "https://qianfan.baidubce.com/v2/app/conversation"

payload = json.dumps({
        "app_id": "0bf75696-d0f2-4c8e-8134-1ed84f09cf16",

    })
headers = {
        'Content-Type': 'application/json',
        'X-Appbuilder-Authorization': 'Bearer bce-v3/ALTAK-mjZA8XcSbWnVQ2DDxqWq9/707175e8d2946c2d0cb2f78c36791e4f808ba241'
    }

response = requests.request("POST", url, headers=headers, data=payload)
data = json.loads(response.text)
#print(response.text)
conversation_id = data["conversation_id"]


url = "https://qianfan.baidubce.com/v2/app/conversation/runs"

payload = json.dumps({
        "app_id": "0bf75696-d0f2-4c8e-8134-1ed84f09cf16",
        "query": input("请输入问题"),
        "stream": False,
        "conversation_id": conversation_id
    })
headers = {
        'Content-Type': 'application/json',
        'X-Appbuilder-Authorization': 'Bearer bce-v3/ALTAK-mjZA8XcSbWnVQ2DDxqWq9/707175e8d2946c2d0cb2f78c36791e4f808ba241'
    }

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

data = json.loads(response.text)
conversation_id = data["answer"]